home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
st80_pr4.lha
/
st80_pre4
/
Foible
/
foible
/
Icon-Tools-PPfix.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
5KB
|
182 lines
'From Objectworks for Smalltalk-80(tm), Version 2.5 of 29 July 1989 on 16 April 1990 at 11:44:52 am'!
!IconManager class methodsFor: 'view creation'!
openOnDir: aDir
" open an icon browser on the directory named aDir"
"IconManager openOnDir: FlowKitDirectory iconDirectory."
| topView listView formView iconDictionary |
(Filename named: aDir) exists
ifFalse: [PopUpNotifier message: 'Error: directory does not exist'.
^nil].
iconDictionary _ self new initDict: aDir.
topView_StandardSystemView
model: iconDictionary
label: 'directory:',aDir
minimumSize: 50@50.
topView borderWidth: 1.
listView_SelectionInListView
on:iconDictionary
aspect: #icon
change: #icon:
list: #iconList
menu: #iconMenu
initialSelection: #currentIcon.
formView_IconEditorView
on: iconDictionary
aspect: #form
menu: #iconMenu.
topView addSubView: listView
in: (0@0 extent: 1@0.6)
borderWidth: 1.
topView addSubView: formView
in: (0@0.6 extent: 1@0.4)
borderWidth: 1.
topView controller open! !
!IconManager class methodsFor: 'retrieving forms'!
getIcon: iconName fromDirectory: dirName
"retrieve an icon from disk "
| directory |
directory _ Filename named: dirName.
directory exists
ifTrue: [directory _ FileDirectory named: directory asString]
ifFalse:
[self error: 'Forms directory ' , dirName , ' does not exist'.
^nil].
directory keysDo: [:each | (iconName match: each)
ifTrue: [^Form readFrom: dirName , (String with: Filename separator) , iconName]].
self error: 'Cannot find icon ' , iconName , ' in directory ' , dirName.
^nil!
getCursor: iconName fromDirectory: dirName
"retrieve an icon from disk"
| directory |
directory _ Filename named: dirName.
directory exists
ifTrue: [directory _ FileDirectory named: directory asString]
ifFalse:
[self error: 'Forms directory ' , dirName , ' does not exist'.
^nil].
directory keysDo: [:each | (iconName match: each)
ifTrue: [^self formToCursor: (Form readFrom: dirName , (String with: Filename separator) , iconName)]].
self error: 'Cannot find cursor ' , iconName , ' in directory ' , dirName.
^nil! !
!IconManager methodsFor: 'initialize/release'!
initDict: aDirName
" set up the dictionary of icons, ignore *.bak files "
directory _ FileDirectory named: aDirName.
(Filename named: aDirName) exists
ifFalse: [PopUpNotifier message: 'Error: directory does not exist'.
^nil].
iconDict _ Dictionary new.
directory keysDo:
[:each | ('*.bak' match: each)
ifFalse: [(iconDict at: each ifAbsent: [nil]) isNil
ifTrue: [iconDict at: each put: nil]]]! !
!IconManager methodsFor: 'menu'!
addIcon
" add a new icon to the current directory"
| newIcon iconName fullName|
iconName_FillInTheBlank request: 'New Icon Name' initialAnswer: ('').
iconName='' ifTrue: [^self].
iconDict isNil ifTrue: [iconDict_Dictionary new].
fullName_self dirFullName,iconName.
(Filename named: fullName) exists
ifFalse:[newIcon_Form extent: self newIconExtent.
newIcon writeOn: fullName]
ifTrue:[PopUpNotifier message: 'An icon with this name already exists in this directory'.
^nil].
iconDict at: iconName put: newIcon.
currentIcon_iconName.
self changed: #icon!
changeDir
| newDir |
newDir _ FillInTheBlank request: 'New Directory:' initialAnswer: (self dirFullName).
newDir = '' ifTrue: [^nil].
(Filename named: newDir) exists
ifFalse: [PopUpNotifier message: 'directory ',newDir,' does not exist'.
^nil].
iconDict _ Dictionary new.
self initDict: newDir.
self changed: #icon!
copyIcon
" copy the current icon to another directory "
| copyDir fullName |
copyDir _ FillInTheBlank request: 'Directory to Copy Icon to:' initialAnswer: (self dirFullName).
copyDir = '' ifTrue: [^self].
(Filename named: copyDir) exists
ifFalse: [PopUpNotifier message: 'directory ',copyDir,' does not exist'.
^nil].
copyDir _ copyDir,(String with: Filename separator),currentIcon.
iconDict isNil ifTrue: [iconDict _ Dictionary new].
fullName _ self pathToCurrent.
FileDirectory copyFileNamed: fullName to: copyDir!
removeIcon
" delete the icon from the current directory"
| file |
file _ Filename named: self pathToCurrent.
(file exists and: [(BinaryChoice message: 'Are you sure that you want to delete ',currentIcon,'?')])
ifTrue:[file delete.
iconDict removeKey: currentIcon.
currentIcon_nil.
self changed: #icon]!
renameIcon
"rename the current icon in the directory"
| newName fullName file |
newName_FillInTheBlank request: 'New Icon Name' initialAnswer: (currentIcon).
newName='' ifTrue: [^self].
fullName_ self dirFullName,newName.
(Filename named: fullName) exists
ifTrue:[PopUpNotifier message: 'An icon with this name already exists in this directory'.
^nil].
(iconDict at:currentIcon) writeOn: fullName.
iconDict at: newName put: (iconDict at: currentIcon).
iconDict removeKey: currentIcon.
file _ Filename named: self pathToCurrent.
file exists ifTrue:[file delete].
currentIcon_newName.
self changed: #icon!
updateList
" update the listing of the directory"
self initDict: self dirFullName.
self changed: #icon! !
!IconEditorView methodsFor: 'displaying'!
display
self isUnlocked ifTrue: [self scrollOffset:0@0].
self displayBorder.
self displayView! !
!IconEditorController methodsFor: 'private'!
scrollDelayLength
"This method is for Textronix compatibility"
^5! !